//
//  NKNavigationViewController.m
//  NKMapTest
//
//  Created by SongGang on 2017/3/6.
//  Copyright © 2017年 NK. All rights reserved.
//

#import "NKNavigationViewController.h"

@interface NKNavigationViewController ()

@end

@implementation NKNavigationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.interactivePopGestureRecognizer.delegate = nil;
}

// 设置bar
+ (void)initialize {

    UINavigationBar *bar = [[UINavigationBar alloc] init];
    [bar setBackgroundColor:[UIColor whiteColor]];
}


// 自定义push返回
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {

    if (self.childViewControllers.count > 0) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:@"返回" forState:UIControlStateNormal];
        button.frame = CGRectMake(0, 0, 70, 30);
        [button setImage:[UIImage imageNamed:@"return"] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"return"] forState:UIControlStateHighlighted];
        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        button.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
        [button setTitleColor: NKBlueColor forState:UIControlStateNormal];
        [button setTitleColor:NKBlueColor forState:UIControlStateHighlighted];
        [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
        
    }
    [super pushViewController:viewController animated:animated];
    
}

- (void)back {

    [self popViewControllerAnimated:YES];
}

@end
